package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.java.po.Department;
import com.java.po.DepartmentMap;
import com.java.service.DepartService;
import com.java.service.impl.DepartServiceImpl;
import com.java.tool.AjaxJson;

/**
 * Title:DepartController.java
 * Description:
 * @author:sprogrammer
 * @time:2018年2月23日下午8:09:19
 */
@Controller
@CrossOrigin()
@RequestMapping(method=RequestMethod.POST)
public class DepartController {
	
	private AjaxJson ajaxJson;
	
	@Autowired
	private DepartService departService;
	
	public DepartController(){
		ajaxJson = new AjaxJson();
		//departService = new DepartServiceImpl();
	}
	
	@RequestMapping(value = "/insertDepartment")
	public @ResponseBody AjaxJson insertDepartment(@RequestBody Department department) throws Exception{
		ajaxJson = departService.insertDepartment(department);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/deleteDepartment")
	public @ResponseBody AjaxJson deleteDepartment(@RequestBody Department department) throws Exception{
		ajaxJson = departService.deleteDepartmentById(department);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/updateDepartment")
	public @ResponseBody AjaxJson updateDepartment(@RequestBody Department department) throws Exception{
		ajaxJson = departService.updateDepartmentById(department);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/findDepartment")
	public @ResponseBody AjaxJson findDepartment(@RequestBody DepartmentMap departmentMap) throws Exception{
		ajaxJson = departService.findAllDepartment(departmentMap);
		return ajaxJson;
	}
	
	@RequestMapping(value ="/findDepartmentByid")
	public @ResponseBody AjaxJson findDepartmentByid(@RequestBody Department department) throws Exception{
		ajaxJson = departService.findDepartmentByid(department);
		return ajaxJson;
	}
	
}
